import sys
import os
import hashlib
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE, SIG_DFL)
args = sys.argv
if len(sys.argv) != 2:
    exit(0)

hash_md5 = hashlib.md5(sys.argv[1].encode("utf-8")).hexdigest()
cache_path_image = "{0}/cache/video_previews/{1}".format(os.getcwd(), hash_md5)
if (os.path.exists(cache_path_image) and os.path.isfile(cache_path_image)) is not True:
    sys.stdout.write("{0}/default.png".format(os.getcwd()))
    sys.exit(0)
sys.stdout.write(cache_path_image)
sys.exit(0)
